package com.sskj.jd.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import com.sskj.core.query.annotation.DynamicQuery;
import com.sskj.core.repository.GenericRepository;
import com.sskj.jd.domain.AnQuanZGTZSQueryParam;
import com.sskj.jd.domain.entity.AnQuanZGTZS;

public interface AnQuanZGTZSRepostiory extends GenericRepository<AnQuanZGTZS, String> {

	@DynamicQuery
	Page<AnQuanZGTZS> findPage(AnQuanZGTZSQueryParam aqQueryParam, Pageable pageable);

	@Query(value = "from AnQuanZGTZS o where o.id=?1")
	AnQuanZGTZS findOneById(String spId);

	@Query(value = "select max(lower(o.coding)) from AnQuanZGTZS o where  1=1" + " and lower(o.coding) like lower(?1)"
			+ " and length(o.coding)=?2")
	String maxCode(String cdlike, Integer cdlen);
}